home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cracking 2
/
Cracking II..iso
/
Priklady
/
Priklad 37
/
B
/
DETECT37.ASM
next >
Wrap
Assembly Source File
|
2000-08-14
|
3KB
|
112 lines
.386p
.MODEL FLAT,STDCALL
locals
jumps
UNICODE=0
include w32.inc
Extrn SetUnhandledExceptionFilter : PROC
Interrupt equ 5 ;cislo prerusenia, cisla 1 alebo 3 stazia debugovanie
.DATA
sprava1 db "Ukazka prepnutia do RING0 pomocou IDT (EliCZ's method)",0
sprava2 db "Nastala chyba",0
sprava3 db "RING0 bol uspesne aktivovany",0
odlozESP dd 0 ;sem uklada register ESP
predchadzajuca dd 0 ;sem uklada adresu predchadzajucej obsluhy SEH
.CODE
Start:
;----------------------------------------------------------------------------
;NASTAVI SEH PRE PRIPAD CHYBY
;----------------------------------------------------------------------------
mov [odlozESP],esp
push offset chyba
call SetUnhandledExceptionFilter
mov [predchadzajuca], eax
;----------------------------------------------------------------------------
push edx
sidt [esp-2] ;nacita IDT do stacku
pop edx
add edx,(Interrupt*8)+4 ;nacita vektor nami pozadovaneho prerusenia
mov ebx,[edx]
mov bx,word ptr [edx-4] ;nacita adresu starej obsluhy nami pozadovaneho prerusenia
lea edi,InterruptHandler
mov [edx-4],di
ror edi,16 ;nastavi novu obsluhu prerusenia
mov [edx+2],di
push ds ;ulozi registre koli bezpecnosti
push es
int Interrupt ;skoci do Ring0 (nami definovana nova obsluha INT 5h)
pop es ;obnovi registre
pop ds
mov [edx-4],bx ;nastavi povodnu obsluhu prerusenia (INT 5h)
ror ebx,16
mov [edx+2],bx
;----------------------------------------------------------------------------
;NASTAVI PREDCHADZAJUCU OBSLUHU SEH
;----------------------------------------------------------------------------
push dword ptr [predchadzajuca]
call SetUnhandledExceptionFilter
;----------------------------------------------------------------------------
jmp skok ;skoci, ak bolo prepnutie do RING0 uspesne
continiue:
call MessageBoxA,0, offset sprava2, offset sprava1,0
call ExitProcess, -1
skok:
call MessageBoxA,0, offset sprava3, offset sprava1,0
call ExitProcess, -1
chyba: ;nova obsluha SEH pre pripad chyby
mov esp, [odlozESP]
push offset continiue
ret
;-----------------------------------------------------------------------------
;NASA NOVA OBSLUHA INT 5h (bezi v Ring0)
;-----------------------------------------------------------------------------
InterruptHandler:
mov eax,dr7 ;tato instrukcia je funkcna iba v RING0
iretd ;skok spat do RING3
ends
end Start